import axios from '@/api/interceptor';
import { LinksQuery, LinksRecord } from '@/api/links/types';

export const selectPageLinks = async (params: LinksQuery) => {
  const result = await axios({
    url: '/links/listPage',
    method: 'GET',
    params,
  });
  return result.data;
};

export const createLinks = async (data: LinksRecord) => {
  const result = await axios({
    url: '/links/createLinks',
    method: 'POST',
    data,
  });
  return result.data;
};

export const removeLinks = async (ids: number[]) => {
  const result = await axios({
    url: '/links/removeLinks',
    method: 'DELETE',
    data: ids,
  });
  return result.data;
};

export const getLinksDetail = async (id: number) => {
  const result = await axios({
    url: '/links/getLinksDetail',
    method: 'GET',
    params: { id },
  });
  return result.data;
};

export const editLinks = async (data: LinksRecord) => {
  const result = await axios({
    url: '/links/editLinks',
    method: 'PUT',
    data,
  });
  return result.data;
};

export const passLinks = async (ids: number[]) => {
  const result = await axios({
    url: '/links/pass',
    method: 'POST',
    data: ids,
  });
  return result.data;
};

export const rejectLinks = async (ids: number[]) => {
  const result = await axios({
    url: '/links/reject',
    method: 'POST',
    data: ids,
  });
  return result.data;
};
